﻿Imports lbGlobalcom
Public Class fTipoPrepacks
    Dim daTipoPrepack As dsInventariosTableAdapters.INV_TIPOSPREPACKSTableAdapter
    Private Sub btnCargarTipoPrepack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCargarTipoPrepack.Click
        Try
            If Me.DsInventarios.INV_TIPOSPREPACKS.GetChanges IsNot Nothing Then
                INV_TIPOSPREPACKSBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    INV_TIPOSPREPACKSBindingNavigatorSaveItem.PerformClick()
                End If
            End If
            daTipoPrepack.Fill(DsInventarios.INV_TIPOSPREPACKS)
        Catch ex As Exception
            lbGlobalcom.cError.SalvaError(ex, "Henry")
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub INV_TIPOSPREPACKSBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INV_TIPOSPREPACKSBindingNavigatorSaveItem.Click
        Try
            Validate()
            INV_TIPOSPREPACKSBindingSource.EndEdit()
            daTipoPrepack.Update(DsInventarios.INV_TIPOSPREPACKS)
            MessageBox.Show("Se salvarón registros con exito", "Salvar Registro", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            lbGlobalcom.cError.SalvaError(ex, "Henry")
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        Try
            If MessageBox.Show("Esta seguro que desea eliminar este registro", "Elimina Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                INV_TIPOSPREPACKSBindingSource.RemoveCurrent()
                daTipoPrepack.Update(DsInventarios.INV_TIPOSPREPACKS)
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub INV_TIPOSPREPACKSDataGridView_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles INV_TIPOSPREPACKSDataGridView.DataError
        MessageBox.Show(e.Exception.Message)
    End Sub

    Private Sub INV_TIPOSPREPACKSDataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles INV_TIPOSPREPACKSDataGridView.UserDeletedRow
        Try
            daTipoPrepack.Update(DsInventarios.INV_TIPOSPREPACKS)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub



    Private Sub INV_TIPOSPREPACKSDataGridView_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) Handles INV_TIPOSPREPACKSDataGridView.UserDeletingRow
        If MessageBox.Show("Esta seguro que desea eliminar este registro", "Elimina Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
            e.Cancel = True
        End If
    End Sub

    Private Sub fTipoPrepacks_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            If Me.DsInventarios.INV_TIPOSPREPACKS.GetChanges IsNot Nothing Then
                INV_TIPOSPREPACKSBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    INV_TIPOSPREPACKSBindingNavigatorSaveItem.PerformClick()
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub fTipoPrepacks_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            daTipoPrepack = New dsInventariosTableAdapters.INV_TIPOSPREPACKSTableAdapter
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub
End Class